package git.soulbgm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import git.soulbgm.mapper.AlarmPromptConfigMapper;
import git.soulbgm.pojo.AlarmPromptConfig;
import git.soulbgm.service.AlarmPromptConfigService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 告警提示配置服务实现类
 *
 * @author SoulBGM
 * @date 2023-04-21
 */
@Service
public class AlarmPromptConfigServiceImpl extends ServiceImpl<AlarmPromptConfigMapper, AlarmPromptConfig> implements AlarmPromptConfigService {

    @Cacheable(value = "alarmPromptConfigMap", sync = true)
    @Override
    public Map<Integer, AlarmPromptConfig> getAlarmPromptConfigMap() {
        return list().stream().collect(Collectors.toMap(AlarmPromptConfig::getLevel, Function.identity()));
    }

}
